package com.xpalive.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.xpalive.base.dto.page.PageReq;
import com.xpalive.base.dto.page.PageRsp;
import com.xpalive.base.service.impl.MyBaseServiceImpl;
import com.xpalive.config.mybatis.toolkit.WrappersProxy;
import com.xpalive.user.dto.UserQuery;
import com.xpalive.user.mapper.UserMapper;
import com.xpalive.user.model.User;
import com.xpalive.user.service.UserService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional(readOnly = true)
@AllArgsConstructor
public class UserServiceImpl extends MyBaseServiceImpl<UserMapper, User> implements UserService {

    @Override
    public PageRsp<User> list(PageReq pagereq, UserQuery userQuery) {
        LambdaQueryWrapper<User> queryWrapper = WrappersProxy.lambdaQuery(User.class);
        queryWrapper.eq(User::getName, userQuery.getName());
        return page(pagereq, queryWrapper, baseMapper::selectPage);
    }

}
